<?php
/*
 * List all the people I followed
 */

// authenticate user first
F3::call('authentication.php');
if (F3::exists('auth_error'))
{
  // authentication failed
  return;
}

// get friend list
$uid = F3::get('SESSION.user_id');
$param = array('1'=>$uid);
$result = DB::sql("SELECT user.id, user.email, user.nickname, user.fname, user.lname
					FROM friends JOIN user on friends.id2 = user.id
					where friends.id1 = ?",$param);
$response = array();
foreach ($result as $row)
{
	$r = array();
	$r['id'] = $row['id'];
	$r['email'] = $row['email'];
	$r['nickname'] = $row['nickname'];
	$r['fname'] = $row['fname'];
	$r['lname'] = $row['lname'];
	array_push($response, $row);
}

header('HTTP/1.1 200');
header("Content-Type: application/json");
echo json_encode($response);
?>